export default class LoginController {
  constructor() {
    this.roleList = [
      {
        id: '1',
        name: '管理员'
      },
      {
        id: '2',
        name: '会员'
      },
      {
        id: '3',
        name: '普通用户'
      },
      {
        id: '4',
        name: '游客'
      }
    ];
    this.formModel = {
      username: 'xiaosa005',
      password: '',
      roles: []
    };
    this.requiredRoles = false;
  }

  $onInit() {
    // console.log(this.roleList);
    this.formModel.roles = this.roleList.map(role => ({id: role.id, checked: false}))
  }

  doLogin() {
    const roles = this.formModel.roles
      .filter(r => r.checked)
      .map(role => role.id);
    this.requiredRoles = (roles.length === 0);
    const param = {
      ...this.formModel,
      roles
    };
    console.log(param);

  }
}